<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS异步</title>
</head>
<body>
<p>使用 setInterval() 显示时间，间隔为一秒（1000 毫秒）。</p>

<h1 id="demo"></h1>
<script>
  setInterval(myFunction, 1000);
  function myFunction() {
    let d = new Date();
    document.getElementById("demo").innerHTML=
            d.getHours() + ":" +
            d.getMinutes() + ":" +
            d.getSeconds();
  }
</script>
</body>
</html>